package com.onesports.intelligent.k12.polarlight.controller.organization.product;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.student.StudentDetailDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.student.StudentManageDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.order.OrderByIdVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentManageVO;
import com.onesports.intelligent.k12.polarlight.service.order.OrderService;
import com.onesports.intelligent.k12.polarlight.service.student.StudentService;
import com.onesports.intelligent.k12.polarlight.service.student.manage.PlatformMembershipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author FPH
 * @since 2022年7月14日09:36:46
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(ApiPathConstants.PRODUCT_STU)
@Api(tags = "机构端-教务管理-学员管理")
@PreAuthorize("isAuthenticated()")
public class StudentManageController {
    private final PlatformMembershipService wxUserService;

    private final StudentService studentService;

    private final OrderService orderService;

    @PostMapping("page")
    @ApiOperation("分页查询")
    public ResponseEntity<IPage<StudentManageVO>> page(@RequestBody @Valid StudentManageDTO dto){
        return ResultUtil.success(studentService.page(dto));
    }

    @PostMapping("detail")
    @ApiOperation("查看详情")
    public ResponseEntity<StudentDetailVO> page(@RequestBody @Valid StudentDetailDTO studentDetailDTO){
        return ResultUtil.success(wxUserService.detailVO(studentDetailDTO.getId(),studentDetailDTO.getCampusIds(),false));
    }

    @GetMapping("detail-d")
    @ApiOperation("查看详情-查看")
    public ResponseEntity<OrderByIdVO> detailD(String orderNo){
        return ResultUtil.success(orderService.selectById(orderNo));
    }
}
